package cn.bby.tools.actions;

import cn.bby.tools.dialog.FieldCompareDialog;
import cn.bby.tools.utils.AnActionEventUtils;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;

/**
 * 字段对比Action
 * 用于触发字段对比对话框
 *
 * @author ben
 * @version 1.0
 */
public class FieldCompareAction extends AnAction {
    
    // 静态状态变量，用于保存最后一次使用的状态

    @Override
    public void actionPerformed(@NotNull AnActionEvent e) {
        Project project = e.getProject();
        if (project == null) {
            return;
        }

        // 获取选中的文本
        String selectedText = AnActionEventUtils.getSelectedText(e);
        FieldCompareDialog dialog = new FieldCompareDialog(project, selectedText);
        dialog.show();
    }
}